package com.rent.common.enums;

import lombok.Getter;

/**
 * 房源状态枚举
 */
@Getter
public enum HouseStatus {
    
    /**
     * 待审核
     */
    PENDING(0, "待审核"),
    
    /**
     * 已上架
     */
    PUBLISHED(1, "已上架"),
    
    /**
     * 已下架
     */
    OFF_SHELF(2, "已下架");
    
    /**
     * 状态代码
     */
    private final Integer code;
    
    /**
     * 状态名称
     */
    private final String name;
    
    HouseStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }
    
    /**
     * 根据代码获取状态
     */
    public static HouseStatus getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (HouseStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}

